/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: asus
 * Date: 2024-12-25
 * Time: 10:18
 */
public class RemoveDuplicates {
    public int removeDuplicates(int[] nums) {
        if (nums.length == 1) {
            return 1;
        }
        int fast = 1, low = 0;
        int count = 1;
        while (fast < nums.length) {
            if (nums[fast] == nums[low]) {
                fast++;
            } else {
                nums[++low] = nums[fast];
                count++;
            }
        }
        return count;
    }
}
